{template "install/header.html"}

<div class="portlet light">
    <div class="portlet-title">
        <div class="caption">
            <i class="fa fa-laptop font-green"></i>
            <span class="caption-subject font-green">{dr_lang('正在安装数据结构')}</span>
        </div>
    </div>
    <div class="portlet-body " style="">

        {if $error}
        <div class="scroller" style="height:300px;" data-rail-visible="1">
            {nl2br($error)}
        </div>
        {else}
        <div class="scroller" style="height:300px; font-size: 12px;" data-rail-visible="1" id="dr_check_html">
            <p>{dr_lang('正在执行安装程序')}</p>
        </div>
        <div id="dr_error_html" style="display: none">
            <!--s-->
            <h5 class="caption-subject font-green">常见问题：</h5>
            <p><a href="javascript:dr_tips(0, '表示你已经安装过，需要返回上一步，改一下数据表前缀字符，例如改成：xr_等等', -1);">Tablespace ** exists</a></p>
            <p><a href="javascript:dr_tips(0, '表示你已经安装过，需要返回上一步，改一下数据表前缀字符，例如改成：xr_等等', -1);">Table ** already exists</a></p>
            <p><a href="https://www.xunruicms.com/doc/1238.html" target="_blank">Index column size too large</a></p>
            <p><a href="https://www.xunruicms.com/doc/1047.html" target="_blank">Unknown storage engine InnoDB</a></p>
            <p><a href="https://www.xunruicms.com/doc/1309.html" target="_blank">Got error ** from storage engine</a></p>
            <p><a href="https://www.xunruicms.com/doc/1409.html" target="_blank">Storage engine MyISAM is disabled</a></p>
            <p><a href="javascript:dr_tips(0, 'Mysql版本太低了，需要在5.7以上或者更高的版本', -1);">SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long</a></p>
            <!--e-->
        </div>
        <script>
            $(function(){
                dr_ajax2ajax(1);
            });
            function dr_ajax2ajax(page) {
                $.ajax({
                    type: "GET",
                    dataType: "json",
                    url: "{$do_url}&page="+page,
                    success: function (json) {

                        $('#dr_check_html').append("<p>"+json.msg+"</p>");
                        document.getElementById('dr_check_html').scrollTop = document.getElementById('dr_check_html').scrollHeight;

                        if (json.code == 0) {
                            $('#dr_check_html').append("<p style='color:red'>出现故障："+json.msg+"</p>");
                            $('#dr_error_html').show();
                            return;
                        } else {
                            if (json.data.page == 99 ) {
                                // 完成
                                var loading = layer.load(2, {
                                    shade: [0.3,'#fff'], //0.1透明度的白色背景
                                    time: 100000000
                                });
                                window.location.href = "{$next_url}&protocol="+document.location.protocol;
                            } else {
                                dr_ajax2ajax(json.data.page);
                            }
                        }
                    },
                    error: function(HttpRequest, ajaxOptions, thrownError) {
                        dr_ajax_alert_error(HttpRequest, this, thrownError);;
                        $('#dr_check_html').append("<p style='color:red'>出现故障："+HttpRequest.responseText+"</p>");
                    }
                });
            }

        </script>
        {/if}

    </div>
    <div class="portlet-title" style="min-height: 18px;">
    </div>
    <div class="portlet-body text-center">
        {if $error}
        <a href="{$pre_url}" class="btn btn-success"> {dr_lang('返回上一步')} </a>
        {/if}
    </div>
</div>
{template "install/footer.html"}